#include<bits/stdc++.h>
using namespace std;

const int N = 1010;
int dp[N][N];
char a[N], b[N];
int m, n;

int main() {
    // ABCDEABCD
    // XAABZ
    scanf("%s%s", a + 1, b + 1);//下标从1开始 便于操作 
    int n = strlen(a + 1), m = strlen(b + 1);
    dp[0][0] = a[1] == b[1] ? 0 : 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] == b[1]) dp[i][0] = 0;
        else dp[i][1] = dp[i - 1][0];
    }
    for (int j = 1; j <= m; j++) {
        if (a[1] == b[j]) dp[0][j] = dp[0][j - 1];
        else dp[0][j] = dp[0][j - 1] + 1;
    } 
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] = min(dp[i][j - 1] + 1, dp[i - 1][j]);
            if (a[i] == b[j]) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
            else dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}
